import random

from selenium.webdriver.common.by import By

from base import BaseAction

year = random.randint(1970, 2000)
month = random.randint(1, 12)
day = random.randint(11, 28)


class CreatePageHome(BaseAction):
    create_order_ele = By.XPATH, '//*[text()="新建订单"]'
    create_name_ele = By.XPATH, '//input[@placeholder="患者姓名"]'
    create_nei = By.XPATH, '//*[text()="基本信息"]'
    sex = random.choice(['男', '女'])
    # create_sex_ele = By.XPATH, f'//input[@value="{sex}"]'
    create_sex_ele = By.XPATH, '//input[@value="男"]/../span'
    create_year_ele = By.XPATH, '//*[@data-tag="年"]//input'
    create_year_ele2 = By.XPATH, f'//*[@id="ZJaddWin"]//span[text()="{year}"]'
    create_month_ele = By.XPATH, '//*[@data-tag="月"]//input'
    create_month_ele2 = By.XPATH, '//*[@id="ZJaddWin"]//span[text()="12"]'
    create_day_ele = By.XPATH, '//*[@data-tag="日"]//input'
    create_day_ele2 = By.XPATH, '//*[@id="date"]/div/p/span[text()="01"]'
    order_list = By.XPATH, '//*[text()="订单列表"]'

    # 订单列表
    def get_order_list_ele(self):
        return self.get_element(self.order_list)
    # 创建订单
    def get_create_order_ele(self):
        return self.get_element(self.create_order_ele)

    # 创建患者信息
    def get_create_name_ele(self):
        return self.get_element(self.create_name_ele)

    def get_create_nei(self):
        return self.get_element(self.create_nei)

    def get_create_sex_ele(self):
        return self.get_element(self.create_sex_ele)

    def get_create_year_ele(self):
        return self.get_element(self.create_year_ele)

    def get_create_month_ele(self):
        return self.get_element(self.create_month_ele)

    def get_create_day_ele(self):
        return self.get_element(self.create_day_ele)

    def get_create_year_ele2(self):
        return self.get_element(self.create_year_ele2)

    def get_create_month_ele2(self):
        return self.get_element(self.create_month_ele2)

    def get_create_day_ele2(self):
        return self.get_element(self.create_day_ele2)
